package com.itheima.homework;

import java.util.Scanner;

public class TestWorker {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请录入工人姓名:");
        String n = sc.nextLine();
        System.out.println("请录入工人的工龄:");
        int y = sc.nextInt();
        Worker w = new Worker();
        w.setName(n);
        w.setYear(y);
        w.show();
        Worker w2 = new Worker(n,y);
        w2.show();
    }
}
class Worker{
    private String name;
    private int year;



    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public Worker(String name, int year){
        this.name = name;
        this.year = year;
    }
    public Worker(){}

    public void show(){
        System.out.println("该工人的信息属性如下:");
        System.out.println("姓名:" + name);
        System.out.println("工龄:" + year);
    }
}